﻿<cfsilent>
	<cfscript>
		
		propertyAdvice = getProperty("serviceFactory").getBean("studentPropertyAdvice");
		
		event.setArg("pageTitle", "成绩管理 - 重复成绩删除");
		
		passArgs = structNew();
		
		currentTab = event.getArg("TabID", "labSearch");
		
		sql = "select t.*,c.course_name, m.stu_name from t_student_mark t,t_course c, t_student m,  
			(select stu_id,cid from (select stu_id,cid from t_student_mark t where stu_id is not null group by stu_id, cid  having count(*) > 1 order by stu_id) ) s 
			 where t.stu_id =s.stu_id and t.cid = s.cid
			  AND c.cid = t.cid 
       		 AND m.stu_id = t.stu_id 
			 order by t.stu_id,t.cid";
			 
		queryObj = new Query( datasource=application.dnsSlave, maxRows=40 );
			
		rs_studentMark = queryObj.execute( sql=sql ).getResult();
		
		
		/* 搜索学生档案 */
		cases = event.getArg("cases");
		HSQL = "";
		keyword = trim(event.getArg("Keywords")) ;
		
		if( cases eq "" OR cases eq "1"){
			cases = "1";
			keyword = ucase(keyword);
			HSQL = "upper( ";
		}else if( cases eq "2"){
			keyword = lcase(keyword);
			HSQL = "Lower( ";
		}else{
			HSQL = "(";
		}
		
		structInsert(passArgs,"cases", cases );
		
		rs_student = queryNew("stu_id");
		
		if ( len(keyword) ) {
			
			
			sql = "select t.*,c.course_name, m.stu_name from t_student_mark t,t_course c, t_student m,  
					(select stu_id,cid from (select stu_id,cid from t_student_mark t where stu_id is not null group by stu_id, cid  having count(*) > 1 order by stu_id) ) s 
					 where t.stu_id =s.stu_id and t.cid = s.cid
					  AND c.cid = t.cid 
					 AND m.stu_id = t.stu_id 
					AND 
						 (
							 " & HSQL & " m.stu_id ) LIKE :condition 
							 OR 
							 " & HSQL & " m.stu_name ) LIKE :condition 
							 OR 
							 " & HSQL & " m.stu_name_english ) LIKE :condition 
							 or 
							 " & HSQL & " m.stu_idcard ) LIKE :condition 
							 OR 
							 " & HSQL & " m.NATIONALITY ) like :condition 
						 )
					ORDER BY 
						t.stu_id, t.cid ";
			
			queryObj = new Query( datasource=application.dnsSlave, maxRows=40 );
			queryObj.addParam( name="condition", value="%"&keyword&"%", cfsqltype="cf_sql_varchar" );
			
			rs_studentMark = queryObj.execute( sql=sql ).getResult();
	
						
		}
		
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('DEFAULT_EVENT')#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">成绩数据维护</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 application"></i>重复成绩删除
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labSearch">class="active"</cfif> id="labSearch" tabTarget="Search">搜索学生</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				
				<div id="Search" class="tabContent">
					
					<form id="formSearch" onSubmit="javascript:return processVerfiyForm('formSearch');" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('studentMarkRepeat',passArgs)#</cfoutput>">
                                   <input type="hidden" name="TabID" value="labSearch" />
                                   
                                   <div class="label">
                                        <b>学号、中文名、国家、<br/>护照名、护照号</b>
                                        <input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
                                        <input name="cases" id="cases" type="radio" class="typeRadio" verification="required" maxlength="128" value="1" <cfif event.getArg('cases', '1') eq 1>checked="checked"</cfif> />大写显示
                                         <input name="cases" id="cases" type="radio" class="typeRadio" verification="required" maxlength="128" value="2" <cfif event.getArg('cases', '1') eq 2>checked="checked"</cfif>/>小写显示
                                          <input name="cases" id="cases" type="radio" class="typeRadio" verification="required" maxlength="128" value="3" <cfif event.getArg('cases', '1') eq 3>checked="checked"</cfif>/>正常显示
                                   </div>
                                   <hr/>
                                   <div class="lable">
                                        <input class="button1" type="submit" value="搜索" /><br/><font color="red">(如果发现删除错误，请不要刷新，直接把错误的截图给技术人员)</font>
                                   </div>
                              </form>
					
					 <cfif rs_studentMark.recordCount>

                    
                              <cfset row = 0 />
                              <table class="UIEditable">
                                   <thead>
                                        <tr>
                                             <td width="18"></td>
                                             <td>学生学号</td>
                                             <td>中文名</td>
                                              <td>课程</td>
                                               <td>学期</td>
                                             <td>期末成绩</td>
                                             <td>补考成绩</td>
                                              <td>学分</td>
                                               <td>绩点</td>
                                                <td>学分绩点</td>
                                             <td width="60">操作</td>
                                        </tr>
                                   </thead>
                                   <tbody>
                                        <cfloop query="rs_studentMark">
                                        
                                           
                                             <cfset row++ />
                                             
                                             <cfset structInsert(passArgs, "STU", rs_studentMark.stu_id, true) />
                                             <cfset structInsert(passArgs, "BOOKID", rs_studentMark.bookedcourse_id, true) />
                                             
                                             
                                             <tr class="editRows" id="<cfoutput>#rs_studentMark.bookedcourse_id#</cfoutput>" rowid="<cfoutput>#rs_studentMark.bookedcourse_id#</cfoutput>">
                                                  <td class="index"><cfoutput>#row#</cfoutput></td>
                                                  <td><cfoutput>#rs_studentMark.stu_id#</cfoutput></td>
                                                  <td><cfoutput>#rs_studentMark.stu_name#</cfoutput></td>
                                                  <td><cfoutput>#rs_studentMark.course_name#</cfoutput></td>
                                                   <td><cfoutput>#rs_studentMark.term_id#</cfoutput></td>
                                                  <td><cfoutput>#rs_studentMark.mark_result#</cfoutput></td>
                                                  <td><cfoutput>#rs_studentMark.mark_resit#</cfoutput></td>
                                                  <td><cfoutput>#rs_studentMark.credit#</cfoutput></td>
                                                  <td><cfoutput>#rs_studentMark.grade_point#</cfoutput></td>
                                                  <td><cfoutput>#rs_studentMark.credit_point_o#</cfoutput></td>
                                                  <td id="delete<cfoutput>#rs_studentMark.bookedcourse_id#</cfoutput>"><a title="删除" href="javascript:void(0);" class="stat delete" rowid="<cfoutput>#rs_studentMark.bookedcourse_id#</cfoutput>"></a></td>
                                                  <td class="hidden_elem" id="show<cfoutput>#rs_studentMark.bookedcourse_id#</cfoutput>">已经删除</td>
                                                      
                                             </tr>
                                        </cfloop>
                                   </tbody>
                              </table>
                              
                                   
                    
                  		</cfif>
					
				</div>
				
			</div>
		</li>
	</ul>
</div>

<script language="javascript" type="text/javascript">
	//<![CDATA[
	<!--
	$(document).ready(function() {
		
		$("a.delete").click(function(){
								
				  var rowid = $(this).attr("rowid");
					  
				  $.post(
						  "<cfoutput>#buildURL('apiMarkDelete')#</cfoutput>", 
						  {
							  'bookedcourseId' : rowid,
							  'seed': (new Date()).getTime()
						  }, 
						  function(data) {
							  
							  result = $.parseJSON(data);
										
							  if (result.success) {
								  var $row = $("tr.editRows[rowid='" + rowid + "']");
							   var $rowdelete = $("td[id='delete" + rowid + "']");
							    var $rowshow = $("td[id='show" + rowid + "']");
							    
							    $rowshow.removeClass("hidden_elem");
							    $rowdelete.addClass("hidden_elem")
							  }else{
									alert(result.reason); 
								}
								
							
								  
							//  $row.hide();
						  });
			  });
	
	});
	
	// -->
	//]]>				
</script>